home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / startx < prev    next >
Encoding:
Text File  |  2006-08-07  |  3.7 KB  |  172 lines

  1. #!/bin/bash
  2.  
  3. # $Xorg: startx.cpp,v 1.3 2000/08/17 19:54:29 cpqbld Exp $
  4. #
  5. # This is just a sample implementation of a slightly less primitive
  6. # interface than xinit. It looks for user .xinitrc and .xserverrc
  7. # files, then system xinitrc and xserverrc files, else lets xinit choose
  8. # its default. The system xinitrc should probably do things like check
  9. # for .Xresources files and merge them in, startup up a window manager,
  10. # and pop a clock and serveral xterms.
  11. #
  12. # Site administrators are STRONGLY urged to write nicer versions.
  13. #
  14. # $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $
  15. userclientrc=$HOME/.xinitrc
  16. sysclientrc=/etc/X11/xinit/xinitrc
  17.  
  18.  
  19. userserverrc=$HOME/.xserverrc
  20. sysserverrc=/etc/X11/xinit/xserverrc
  21. defaultclient=xterm
  22. defaultserver=/usr/bin/X
  23. defaultclientargs=""
  24. defaultserverargs=""
  25. clientargs=""
  26. serverargs=""
  27.  
  28. if [ -f $userclientrc ]; then
  29.     defaultclientargs=$userclientrc
  30. elif [ -f $sysclientrc ]; then
  31.     defaultclientargs=$sysclientrc
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. fi
  39. if [ -f $userserverrc ]; then
  40.     defaultserverargs=$userserverrc
  41. elif [ -f $sysserverrc ]; then
  42.     defaultserverargs=$sysserverrc
  43. fi
  44.  
  45. whoseargs="client"
  46. while [ x"$1" != x ]; do
  47.     case "$1" in
  48.     # '' required to prevent cpp from treating "/*" as a C comment.
  49.     /''*|\./''*)
  50.  if [ "$whoseargs" = "client" ]; then
  51.      if [ x"$clientargs" = x ]; then
  52.   client="$1"
  53.      else
  54.   clientargs="$clientargs $1"
  55.      fi
  56.  else
  57.      if [ x"$serverargs" = x ]; then
  58.   server="$1"
  59.      else
  60.   serverargs="$serverargs $1"
  61.      fi
  62.  fi
  63.  ;;
  64.     --)
  65.  whoseargs="server"
  66.  ;;
  67.     *)
  68.  if [ "$whoseargs" = "client" ]; then
  69.      clientargs="$clientargs $1"
  70.  else
  71.      # display must be the FIRST server argument
  72.      if [ x"$serverargs" = x ] && \
  73.    expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
  74.   display="$1"
  75.      else
  76.   serverargs="$serverargs $1"
  77.      fi
  78.  fi
  79.  ;;
  80.     esac
  81.     shift
  82. done
  83.  
  84. # process client arguments
  85. if [ x"$client" = x ]; then
  86.     # if no client arguments either, use rc file instead
  87.     if [ x"$clientargs" = x ]; then
  88.  client="$defaultclientargs"
  89.     else
  90.  client=$defaultclient
  91.     fi
  92. fi
  93.  
  94. # process server arguments
  95. if [ x"$server" = x ]; then
  96.     # if no server arguments or display either, use rc file instead
  97.     if [ x"$serverargs" = x -a x"$display" = x ]; then
  98.  server="$defaultserverargs"
  99.     else
  100.  server=$defaultserver
  101.     fi
  102. fi
  103.  
  104. if [ x"$XAUTHORITY" = x ]; then
  105.     XAUTHORITY=$HOME/.Xauthority
  106.     export XAUTHORITY
  107. fi
  108.  
  109. removelist=
  110.  
  111.  
  112. # set up default Xauth info for this machine
  113. case `uname` in
  114. Linux*)
  115.  if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
  116.   hostname=`hostname -f`
  117.  else
  118.   hostname=`hostname`
  119.  fi
  120.  ;;
  121. *)
  122.  hostname=`hostname`
  123.  ;;
  124. esac
  125.  
  126. authdisplay=${display:-:0}
  127. mcookie=`/usr/bin/mcookie`
  128. dummy=0
  129.  
  130. # create a file with auth information for the server. ':0' is a dummy.
  131. xserverauthfile=$HOME/.serverauth.$$
  132. xauth -q -f $xserverauthfile << EOF
  133. add :$dummy . $mcookie
  134. EOF
  135. serverargs=${serverargs}" -auth "${xserverauthfile}
  136.  
  137. # now add the same credentials to the client authority file
  138. # if '$displayname' already exists don't overwrite it as another
  139. # server man need it. Add them to the '$xserverauthfile' instead.
  140. for displayname in $authdisplay $hostname$authdisplay; do
  141.      authcookie=`xauth list "$displayname" \
  142.        | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
  143.     if [ "z${authcookie}" = "z" ] ; then
  144.         xauth -q << EOF
  145. add $displayname . $mcookie
  146. EOF
  147.  removelist="$displayname $removelist"
  148.     else
  149.         dummy=$(($dummy+1));
  150.         xauth -q -f $xserverauthfile << EOF
  151. add :$dummy . $authcookie
  152. EOF
  153.     fi
  154. done
  155. xinit $client $clientargs -- $server $display $serverargs
  156.  
  157.  
  158. if [ x"$removelist" != x ]; then
  159.     xauth remove $removelist
  160. fi
  161. if [ x"$xserverauthfile" != x ]; then
  162.     rm -f $xserverauthfile
  163. fi
  164.  
  165.  
  166.  
  167.  
  168.  
  169. if command -v deallocvt > /dev/null 2>&1; then
  170.     deallocvt
  171. fi
  172.